import db from '~~/DB';
import { defineResponseResolver } from '~~/mocks/define';
import {} from 'msw';
import { validateMenu } from '~~/mocks/middleware/menu';

export default validateMenu('system-menu-update', async (req, res, ctx) => {
  const body = await req.json();

  const data = await db.menus.update(req.params.key, {
    parent: body?.parent,
    title: body?.title,
    path: body?.path,
    icon: body?.icon,
    type: body?.type,
    status: body?.status,
    updateTime: new Date(),
  });
  // toCollection().sortBy('sort');
  return res(ctx.json(!!data));
});
